package org.dfzt.modules.online.cgreport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.dfzt.common.util.oConvertUtils;
import org.dfzt.modules.online.cgreport.entity.OnlCgreportItem;
import org.dfzt.modules.online.cgreport.mapper.OnlCgreportItemMapper;
import org.dfzt.modules.online.cgreport.service.IOnlCgreportItemService;
import org.springframework.stereotype.Service;


@Service("onlCgreportItemServiceImpl")
public class OnlCgreportItemServiceImpl
        extends ServiceImpl<OnlCgreportItemMapper, OnlCgreportItem>
        implements IOnlCgreportItemService {
    @Override
    public List<Map<String, String>> getAutoListQueryInfo(String cgrheadId) {
        LambdaQueryWrapper<OnlCgreportItem> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(OnlCgreportItem::getCgrheadId, cgrheadId);
        lambdaQueryWrapper.eq(OnlCgreportItem::getIsSearch, Integer.valueOf(1));
        List<OnlCgreportItem> list = list(lambdaQueryWrapper);
        ArrayList arrayList = new ArrayList();
        byte b = 0;
        for (OnlCgreportItem onlCgreportItem : list) {
            HashMap hashMap = new HashMap();
            hashMap.put("label", onlCgreportItem.getFieldTxt());
            if (oConvertUtils.isNotEmpty(onlCgreportItem.getDictCode())) {
                hashMap.put("view", "list");
            } else {
                hashMap.put("view", onlCgreportItem.getFieldType().toLowerCase());
            }
            hashMap.put("mode", oConvertUtils.isEmpty(onlCgreportItem.getSearchMode()) ? "single" : onlCgreportItem.getSearchMode());
            hashMap.put("field", onlCgreportItem.getFieldName());
            if (++b > 2) {
                hashMap.put("hidden", "1");
            }
            arrayList.add(hashMap);
        }
        return arrayList;
    }
}
